
package oracle.apps.financials.collection.po;

import greendroid.widget.AsyncImageView;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cyrilmottier.android.greendroid.R;


public class ThumbnailItemView extends RelativeLayout implements ItemView {

	private TextView mTextView;
	private TextView mSubtitleView;
	private AsyncImageView mThumbnailView;
	private Button reassignButton;

	public ThumbnailItemView(Context context) {
		this(context, null);
	}

	public ThumbnailItemView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public ThumbnailItemView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public void prepareItemView() {
		mTextView = (TextView) findViewById(R.id.gd_text);
		mSubtitleView = (TextView) findViewById(R.id.gd_subtitle);
		mThumbnailView = (AsyncImageView) findViewById(R.id.gd_thumbnail);
		reassignButton = (Button) findViewById(R.id.gd_reassign);
	}

	public void setObject(Item object) {
		final ThumbnailItem item = (ThumbnailItem) object;
		mTextView.setText(item.text);
		mSubtitleView.setText(item.subtitle);
		mThumbnailView.setDefaultImageResource(item.drawableId);
		mThumbnailView.setUrl(item.drawableURL);
		if (item.onClickListener != null) {
			this.reassignButton.setOnClickListener(item.onClickListener);
		}

	}
}
